package com.qijian.maindata.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.qijian.maindata.domain.CommonClassify;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 通用树形分类Mapper接口
 *
 * @author qijian
 * @date 2021-12-23
 */
public interface CommonClassifyMapper extends BaseMapper<CommonClassify> {

    @Select("select count(0)+IF(#{isAddOne},1,0) from sys_classify WHERE create_time >= CURRENT_DATE ")
    int countCurrentDateWithDel(boolean isAddOne);

    List<CommonClassify> selectListVo(@Param(Constants.WRAPPER) QueryWrapper<CommonClassify> wrapper);

    /**
     * 金蝶同步数据需要
     * 更换id
     * ！！！ 慎用
     *
     * @param old
     * @param newestId
     */
    @Update("update sys_classify set id = #{newestId} where id = #{old}")
    void updateIdById(@Param("old") Long old, @Param("newestId") Long newestId);
    CommonClassify getParentName(@Param("id")Long id);

    List<CommonClassify> getParentNameByIds(@Param("ids")List<Long> ids);
}
